/**
 * Created by ZFL on 2018/3/30.
 */
/**
 * Created by ZFL on 2017/11/23.
 */
/**
 * Created by ZFL on 2017/9/22.
 */
var vm=new Vue({
    el:"#join",
    data:{
        selTerm:4,    //选择的期限   默认是3
        vipInfo:[],   //店主信息
    }
})
function appInit(){
    PageInit()
}
function PageInit(){
    getTerms();

}

function selectTerms(item){
    vm.selTerm=item.talentType;

}
function getTerms(){
    $.ajaxHandler({
        model:function(){
            var obj={};
            obj.userId=0;
            //obj.userId=(JSON.parse($.getStorage('xm_uData')).userId);
            //obj.userId= $.getStorage('xmOpenid');
            obj.type=1;
            return obj;
        },
        visibleTime: 0,
        dataType: "json",
        api:'yg_baijiaapp/talent/talentSalePrice',
        success:function(result){
            if(result.code==10000){
                var data=result.data;
                data.vipInfo.forEach(function(value,index){
                    value.money=divideNumber(value.money,100);
                    vm.vipInfo.unshift(value);
                })
            }else{
                YDUI.dialog.toast(result.message, 'error', 1000);
            }
        }
    })

}
function selectpayWays(type){
    //支付宝支付
    if(type==0){
        $('.alipay i').addClass('active');
        $('.wxpay i').removeClass('active')
    }else{
        //微信支付
        $('.alipay i').removeClass('active');
        $('.wxpay i').addClass('active')

    }
}
//立即支付
function goPay(){
   var payType=0;
    var talentType=vm.selTerm;
    if($('.alipay i').hasClass('active')){
        payType=2;   //支付宝支付
    }else if($('.wxpay i').hasClass('active')){
        payType=1;   //微信支付
    }
    console.log(talentType)
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    var url='';
    var scheme='';
    if(isAndroid){

        JSAndroid.topay(payType,talentType);
    }else if(isiOS){
        //window.webkit.messageHandlers.shareBooking.postMessage(this.data.activity.id,this.data.activity.join_company_id);
        topay(payType,talentType);
    }
}







//显示灰色 jQuery 遮罩层
function showBg() {
    var bh = $("body").height();
    var bw = $("body").width();
    $("#fullbg").css({
        height:bh,
        width:bw,
        display:"block",
    });
    $("#dialog").show()
    $('body').css("overflow","hidden")
    ;

}
//关闭灰色 jQuery 遮罩
function closeBg(){
    $("#fullbg,#dialog").hide();
    $('body').css("overflow","visible")
    location.href ='/b2c/app/downloadApp.html';
}
